<!DOCTYPE html>
<html>
<head>
    <title>Layui原始方案</title>
    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
    <style>
        .select-container {
            margin: 20px;
            display: flex;
            align-items: center;
            gap: 20px;
        }
        .ball-container {
            width: 200px;
            height: 60px;
            border: 1px solid #ccc;
            position: relative;
        }
        .ball {
            width: 20px;
            height: 20px;
            background-color: red;
            border-radius: 50%;
            position: absolute;
            animation: moveBall 4s linear infinite;
        }
        @keyframes moveBall {
            0% { left: 0; top: 0; }
            25% { left: calc(100% - 20px); top: 0; }
            50% { left: calc(100% - 20px); top: calc(100% - 20px); }
            75% { left: 0; top: calc(100% - 20px); }
            100% { left: 0; top: 0; }
        }
    </style>
</head>
<body class="layui-form">
    <div class="select-container">
        <label>省份选择：</label>
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 300px;">
                <select name="province" id="provinceSelect" lay-filter="province" lay-search lay-verify="required">
                    <option value="">请选择省份</option>
                </select>
            </div>
        </div>
        <div class="ball-container">
            <div class="ball"></div>
        </div>
    </div>

    <div class="select-container">
        <label>城市选择：</label>
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 300px;">
                <select name="city" id="citySelect" lay-filter="city" lay-search lay-verify="required">
                    <option value="">请选择城市</option>
                </select>
            </div>
        </div>
    </div>

    <div class="select-container">
        <label>区域选择：</label>
        <div class="layui-inline">
            <div class="layui-input-inline" style="width: 300px;">
                <select name="area" id="areaSelect" lay-filter="area" lay-search lay-verify="required">
                    <option value="">请选择区域</option>
                </select>
            </div>
        </div>
    </div>

    <script src="https://www.layuicdn.com/layui/layui.js"></script>
    <script>
        layui.use(['form', 'layer'], function() {
            var form = layui.form;
            var layer = layui.layer;
            var $ = layui.$;

            // 生成测试数据
            function generateMockData(prefix, count) {
                return Array.from({ length: count }, (_, i) => ({
                    value: i,
                    text: `${prefix}-${i}`
                }));
            }

            // 直接加载选项
            function loadOptions(selectId, data) {
                const select = document.getElementById(selectId);
                const fragment = document.createDocumentFragment();

                data.forEach(item => {
                    const option = document.createElement('option');
                    option.value = item.value;
                    option.text = item.text;
                    fragment.appendChild(option);
                });

                select.appendChild(fragment);
                form.render('select');
            }
            
            // 初始化数据
            const provinceData = generateMockData('省份', 100);
            const cityData = generateMockData('城市', 8000);
            const areaData = generateMockData('区域', 10000);

            // 加载数据
            loadOptions('provinceSelect', provinceData);
            loadOptions('citySelect', cityData);
            loadOptions('areaSelect', areaData);

            // 监听选择事件
            form.on('select(province)', function(data) {
                if (data.value) {
                    layer.msg('选择的省份：' + data.value);
                }
            });

            form.on('select(city)', function(data) {
                if (data.value) {
                    layer.msg('选择的城市：' + data.value);
                }
            });

            form.on('select(area)', function(data) {
                if (data.value) {
                    layer.msg('选择的区域：' + data.value);
                }
            });
        });
    </script>
    <script src="performance-monitor.js"></script>
    <script>
        // 在你的页面脚本中
        const monitor = new PerformanceMonitor({
            warningThreshold: 30,
            showPanel: true,
            historySize: 10,
            updateInterval: 500,
            solutionName: 'Layui原始方案',
            onFPSUpdate: ({ fps, avgFps }) => {
                if (fps < 30) {
                    console.warn(`[Layui原始方案][${new Date().toLocaleTimeString()}] 性能警告: FPS=${fps}`);
                }
            }
        });

        document.addEventListener('DOMContentLoaded', () => {
            monitor.start();
        });
    </script>
</body>
</html>